package com.mythesis.bpel.ui.client.property;

import java.util.ArrayList;

import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.Node;
import com.google.gwt.xml.client.NodeList;
import com.google.gwt.xml.client.XMLParser;

public class PropertiesFactory {
	public static ArrayList parseXML(String xml){
		ArrayList arr = new ArrayList();
		Document doc = XMLParser.parse(xml);
		NodeList nodeList = doc.getElementsByTagName("Property");
		
		for(int i = 0;i < nodeList.getLength();i++){
			NodeList children = nodeList.item(i).getChildNodes();
			String[] properties = new String[3];
			if(children.getLength() == 3){
				properties[0] = children.item(0).getFirstChild().getNodeValue();
				properties[1] = children.item(1).getFirstChild().getNodeValue();
				properties[2] = children.item(2).getFirstChild().getNodeValue();
				arr.add(properties);
			}
		}
		return arr;
	}
}
